
<?php #20070415 http://www.framework.altervista.org/FrameWork/blocks/top/01_title/block.inc
define('BLOCKTITLE','1.00');

/************************************************************************/
/* FrameWork  test preview                                              */
/* ==================================================================== */
/*                                                                      */
/* This program is free software. You can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 2 of the License.       */
/************************************************************************/

/* title.inc */
structure_openBlock("table block calendar","FW","");

//se e' incluso il logo nel blocco lo usa altrimenti lo cerca nel tema
function logopath($path,$block){
    if ((defined('LIBGROUP') && group_getusergroup("webmaster",user_getuser())) || admin_isadmin()){
	if ($_GET['op']=="upload_title" ){
	    if (!file_exists("datas/blocks/images"))mkdir("datas/blocks/images");
	    if (move_uploaded_file($_FILES['image']['tmp_name'], "datas/blocks/images/logo".substr($_FILES['image']['name'],-4))) {
		if (strtolower(substr($_FILES['image']['name'],-4))==".php" ){
		    unlink("datas/blocks/images/logo".substr($_FILES['image']['name'],-4));
		}
		else{
		    echo "<script>alert('immagine ".$_FILES['image']['name']." caricata');</script>";
		}
	    }
	}
	if ($_GET['op']=="delete_title" ){
	    if (file_exists("datas/blocks/images/logo.gif"))
		unlink("datas/blocks/images/logo.gif");
	    if (file_exists("datas/blocks/images/logo.png"))
		unlink("datas/blocks/images/logo.png");
	    if (file_exists("datas/blocks/images/logo.jpg"))
		unlink("datas/blocks/images/logo.jpg");
	}
    }
  if  (file_exists("datas/blocks/images/logo.gif"))
    return "datas/blocks/images/logo.gif";

  if  (file_exists("datas/blocks/images/logo.png"))
    return "datas/blocks/images/logo.png";

  if  (file_exists("datas/blocks/images/logo.jpg"))
    return "datas/blocks/images/logo.jpg";


  if  (file_exists("themes/".theme()."/images/logo.png"))
      return "themes/".theme()."/images/logo.png";

  if  (file_exists("themes/".theme()."/images/logo.gif"))
      return "themes/".theme()."/images/logo.gif";

  if  (file_exists("$path/$block/images/logo.png"))
    return "$path/$block/images/logo.gif";

  if  (file_exists("$path/$block/images/logo.gif"))
    return "$path/$block/images/logo.gif";
}

?>
<style type="text/css" >

div.table.title
{
	border: none;
	background: transparent;
	text-align: center;
}
</style>

<div class='table title'>

  <?php if (logopath($path,$block)) { ?>
    <a href='index.php'><img src='<?=logopath($path,$block);?>' border='0' /></a>
  <?php } ?>


<?php if ((defined('LIBGROUP') && group_getusergroup("webmaster",user_getuser())) || admin_isadmin()){ ?>
    <span style="font-size: 10px; text-align: right;" >
    <form name="images_upload" action="index.php?op=upload_title" enctype='multipart/form-data' method='post'>
    carica un immagine<input type="file" name="image"><input type=submit value="load">
    <a href="index.php?op=delete_title">elimina</a>
    </form>
    </span>
<?php } ?>
</div>

<?php structure_closeBlock(); ?>
